﻿toggle = function (fsid)
{
    var div = $id("div_" + fsid);
    var btnCancel = $id("btnCancel_" + fsid);
    var btnSave = $id("btnSave_" + fsid);
    var load = $id("load_" + fsid);
        
    var display = "";
    
    if( div.style.display != "none" )
    {
        display = "none";
    }
    
    div.style.display = display;
    if(btnCancel != null && btnSave != null)
    {
        btnCancel.style.display = display;
        btnSave.style.display = display;
        load.style.display = display;
    }
    //btn.style.display = display;
    
}
EditPlannedDate = function(cvid)
{
    var div = $id("popuplayer");    div.style.display = "block";    div.innerHTML = "<img src='" + LOADING.src + "' alt='' />";    renderFirst();        cbkList_c.PerformCallback("EDIT" + DELIMITER + cvid); 
}
cbkList_c_CallbackComplete = function(e){
    if( e.parameter.startsWith("EDIT") )
    {
        var div = $id("popuplayer");
        div.innerHTML = e.result;    }
    else if( e.parameter.startsWith("SAVE"))
    {
        closeEditPlannedDate();
        dgVisitView_c.PerformCallback("REFRESH");
    }
}
closeEditPlannedDate = function(){
    var div = $id("popuplayer");    div.innerHTML = "";    div.style.display = "none";
}
saveEditPlannedDate = function(iCVID)
{
    var load = $id("load");
    //var btn = $id("btn_CCNew");
    if(confirm("save changes?"))
    {
        //alert(iCCID);
        // di sini kirim data perubahannya
        var input = getData(iCVID);
        alert (input);
        //btn.style.display = "none";
        load.innerHTML = "<img src='" + LOADING.src + "' alt='' />"; 
        cbkList_c.PerformCallback(input);
    }
}
getData = function(iCVID)
{
    var inputs = $id("CV.VISITDATETIME");
    var output = "SAVE" + DELIMITER +iCVID + DELIMITER + inputs.value;
    return output;
}
DoCancel = function(iCVID)
{
    var reason = $id("reasonEditor");
    if(confirm("Cancel Plan?"))
    {
        dgVisitView_c.PerformCallback("CANCEL" + DELIMITER + iCVID + DELIMITER + reason.value);
    } 
}